package svc

import (
	"api/client/friendClient"
	"api/client/groupClient"
	"api/client/messageClient"
	"api/client/userClient"
	"api/internal/config"
	"github.com/zeromicro/go-queue/kq"
	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config         config.Config
	UserRPC        userClient.User
	FriendRPC      friendClient.Friend
	GroupRPC       groupClient.Group
	MessageRPC     messageClient.Message
	KqPusherClient *kq.Pusher
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:         c,
		UserRPC:        userClient.NewUser(zrpc.MustNewClient(c.UserRPC)),
		FriendRPC:      friendClient.NewFriend(zrpc.MustNewClient(c.FriendRPC)),
		GroupRPC:       groupClient.NewGroup(zrpc.MustNewClient(c.GroupRPC)),
		MessageRPC:     messageClient.NewMessage(zrpc.MustNewClient(c.MessageRPC)),
		KqPusherClient: kq.NewPusher(c.KqPusherConf.Brokers, c.KqPusherConf.Topic),
	}
}
